﻿/*
 * Rappelz: Endless Odyssey - The first free open source Rappelz server emulator
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rappelz.GameServer
{
    public struct Elemental
    {
        public enum Type
        {
            TypeNone = 0,
            TypeFire = 1,
            TypeWater = 2,
            TypeWind = 3,
            TypeEarth = 4,
            TypeLight = 5,
            TypeDark = 6,
            TypeCount = 7
        };

    };

    public class ItemBase
    {
        public const int MAX_COOLTIME_GROUP = 40;
        public const int MAX_OPTION_NUMBER = 4;
        public const int MAX_SOCKET_NUMBER = 4;
        public const int MAX_ITEM_NAME_LENGTH = 32;
        public const int MAX_ITEM_WEAR = 24;

        public enum ItemWearType : int
        {
            WearCantWear = -1,
            WearNone = -1,
            WearWeapon = 0,
            WearShield = 1,
            WearArmor = 2,
            WearHelm = 3,
            WearGlove = 4,
            WearBoots = 5,
            WearBelt = 6,
            WearMantle = 7,
            WearArmulet = 8,
            WearRing = 9,
            WearSecondRing = 10,
            WearEarring = 11,
            WearFace = 12,
            WearHair = 13,
            WearDecoWeapon = 14,
            WearDecoShield = 15,
            WearDecoArmor = 16,
            WearDecoHelm = 17,
            WearDecoGloves = 18,
            WearDecoBoots = 19,
            WearDecoMantle = 20,
            WearDecoShoulder = 21,
            WearRideItem = 22,
            WearBagSlot = 23,
            WearTwoFingerRing = 94,
            WearTwoHand = 99,
            WearSkill = 100,
            WearRightHand = 0,
            WearLeftHand = 1,
            WearBullet = 1,
        }

        public enum ItemClass : int
        {
            ClassEtc = 0,
            ClassDoubleAxe = 95,
            ClassDoubleSword = 96,
            ClassDoubleDagger = 98,
            ClassEveryWeapon = 99,
            ClassEtcWeapon = 100,
            ClassOneHandSword = 101,
            ClassTwoHandSword = 102,
            ClassDagger = 103,
            ClassSpear = 104,
            ClassTwoHandAxe = 105,
            ClassOneHandMace = 106,
            ClassTwoHandMace = 107,
            ClassHeavyBow = 108,
            ClassLightBow = 109,
            ClassCrossBow = 110,
            ClassOneHandStaff = 111,
            ClassTwoHandStaff = 112,
            ClassOneHandAxe = 113,
            ClassArmor = 200,
            ClassFighterArmor = 201,
            ClassHunterArmor = 202,
            ClassMagicianArmor = 203,
            ClassSummonerArmor = 204,
            ClassShield = 210,
            ClassHelm = 220,
            ClassBoots = 230,
            ClassGloves = 240,
            ClassBelt = 250,
            ClassMantle = 260,
            ClassEtcAccessory = 300,
            ClassRing = 301,
            ClassEarring = 302,
            ClassArmulet = 303,
            ClassEyeglass = 304,
            ClassMask = 305,
            ClassCube = 306,
            ClassBoostChip = 400,
            ClassSoulStone = 401,
            ClassDecoShield = 601,
            ClassDecoArmor = 602,
            ClassDecoHelm = 603,
            ClassDecoGloves = 604,
            ClassDecoBoots = 605,
            ClassDecoMantle = 606,
            ClassDecoShoulder = 607,
            ClassDecoHair = 608,
            ClassDecoOneHandSword = 609,
            ClassDecoTwoHandSword = 610,
            ClassDecoDagger = 611,
            ClassDecoTwoHandSpear = 612,
            ClassDecoTwoHandAxe = 613,
            ClassDecoOneHandMace = 614,
            ClassDecoTwoHandMace = 615,
            ClassDecoHeavyBow = 616,
            ClassDecoLightBow = 617,
            ClassDecoCrossBow = 618,
            ClassDecoOneHandStaff = 619,
            ClassDecoTwoHandStaff = 620,
            ClassDecoOneHandAxe = 621,
        }

        public enum ItemType : int
        {
            TypeEtc = 0,
            TypeArmor = 1,
            TypeCard = 2,
            TypeSupply = 3,
            TypeCube = 4,
            TypeCharm = 5,
            TypeUse = 6,
            TypeSoulStone = 7,
            TypeUseCard = 8,
        }

        public enum ItemFlag : uint
        {
            FlagCantDonate = 0x01,
            FlagCantStore = 0x02,
            FlagCantEnhance = 0x04,
            FlagCanWear = 0x08,
            FlagCard = 0x10,
            FlagSocket = 0x20,
            FlagCanJoin = 0x40,
            FlagTargetUse = 0x80,
            FlagWarp = 0x100,
            FlagCantTrade = 0x200,
            FlagCantSell = 0x400,
            FlagQuest = 0x800,
            FlagCantUseOverWeight = 0x1000,
            FlagCashItem = 0x2000,
            FlagCantUseRiding = 0x4000,
            FlagCantDrop = 0x8000,
            FlagCantUseMoving = 0x10000,
            FlagQuestDistribute = 0x20000,
            FlagCanUseSitting = 0x40000,
            FlagCantUseInRaid = 0x80000,
            FlagCantUseInSecRoute = 0x100000,
            FlagCantUseInEventMap = 0x200000,
            FlagCantUseInHuntaholic = 0x400000,
            FlagHuntaholicUsableOnly = 0x800000,
        }

        public enum ItemGroup : int
        {
            Etc = 0,
            Weapon = 1,
            Armor = 2,
            Shield = 3,
            Helm = 4,
            Glove = 5,
            Boots = 6,
            Belt = 7,
            Mantle = 8,
            Accessory = 9,
            SkillCard = 10,
            ItemCard = 11,
            SpellCard = 12,
            SummonCard = 13,
            Face = 15,
            Underwear = 16,
            Bag = 17,
            PetCage = 18,
            StrikeCube = 21,
            DefenseCube = 22,
            SkillCube = 23,
            RestorationCube = 24,
            SoulStone = 93,
            Bullet = 98,
            Consumable = 99,
            NpcFace = 100,
            Deco = 110,
            Riding = 120,
            ElementaEffector = 130,
            ElementalEffectEnhancer = 140,
        }

        public enum LimitFlag : int
        {
            Deva = 0x04,
            Asura = 0x08,
            Gaia = 0x10,
            Fighter = 0x400,
            Hunter = 0x800,
            Magician = 0x1000,
            Summoner = 0x2000,
        }


//     v1->baseclass_8.baseclass_0.nLimit = 0;
//     if ( v1->limit_asura )
//         v1->baseclass_8.baseclass_0.nLimit = 8;
//     if ( v1->limit_gaia )
//         v1->baseclass_8.baseclass_0.nLimit |= 0x10u;
//     if ( v1->limit_deva )
//         v1->baseclass_8.baseclass_0.nLimit |= 4u;
//     if ( v1->limit_hunter )
//         v1->baseclass_8.baseclass_0.nLimit |= 0x800u;
//     if ( v1->limit_fighter )
//         v1->baseclass_8.baseclass_0.nLimit |= 0x400u;
//     if ( v1->limit_magician )
//         v1->baseclass_8.baseclass_0.nLimit |= 0x1000u;
//     if ( v1->limit_summoner )
//         v1->baseclass_8.baseclass_0.nLimit |= 0x2000u;


        // Enum           :   <unnamed-tag>, Type: int
        // Data           :     constant 0x186A1, Constant, Type: int, ITEM_CODE_WEARED_BULLET
        // Enum           :   <unnamed-tag>, Type: int
        // Data           :     constant 0x77A11, Constant, Type: int, ITEM_CODE_BEGINNERS_BAG
        // Data           :     constant 0xDBBA0, Constant, Type: int, ITEM_CODE_STAMINA_SAVER
        // Data           :     constant 0xDBBAA, Constant, Type: int, ITEM_CODE_STAMINA_SAVER_NOT_FOR_SALE
        // Data           :     constant 0xDBBAB, Constant, Type: int, ITEM_CODE_STAMINA_SAVER_FOR_NOVICE
        // Data           :     constant 0x1E854B, Constant, Type: int, ITEM_CODE_STAMINA_SAVER_OF_LOVE
        // Data           :     constant 0xDE2B4, Constant, Type: int, ITEM_CODE_FAIRY_POTION
        // Data           :     constant 0xDE2B5, Constant, Type: int, ITEM_CODE_GRAND_FAIRY_POTION
        // Data           :     constant 0x2C481A, Constant, Type: int, ITEM_CODE_GRAND_FAIRY_POTION_BY_PLAYPOINT
        // Data           :     constant 0x1EAD56, Constant, Type: int, ITEM_CODE_GRAND_FAIRY_POTION_NOT_FOR_SALE
        // Data           :     constant 0xDE2B6, Constant, Type: int, ITEM_CODE_RETURN_FEATHER
        // Data           :     constant 0xDE2B9, Constant, Type: int, ITEM_CODE_RETURN_BACK_FEATHER
        // Data           :     constant 0x2C4858, Constant, Type: int, ITEM_CODE_EVENT_RETURN_FEATHER
        // Data           :     constant 0x8954A2, Constant, Type: int, ITEM_CODE_RUPPI_RETURN_FEATHER
        // Data           :     constant 0xE09C5, Constant, Type: int, ITEM_CODE_FAIRY_LOCK
        // Data           :     constant 0xDE2C7, Constant, Type: int, ITEM_CODE_SECROUTE_WARP_TICKET
        // Data           :     constant 0xC4F98, Constant, Type: int, ITEM_CODE_HUNTAHOLIC_POINT_TICKET
        // Data           :     constant 0xE30F8, Constant, Type: int, ITEM_CODE_RENAME_CHARACTER_TYPE1
        // Data           :     constant 0xE30FA, Constant, Type: int, ITEM_CODE_RENAME_CHARACTER_TYPE2
        // Data           :     constant 0x1EAD5B, Constant, Type: int, ITEM_CODE_RENAME_CHARACTER_TYPE3
        // Data           :     constant 0xEA613, Constant, Type: int, ITEM_CODE_MIRROR_OF_TAMING_CARD
        // Enum           :   ITEM_FLAG, Type: int
        // Data           :     constant 0x0, Constant, Type: int, FLAG_CANT_DONATE
        // Data           :     constant 0x1, Constant, Type: int, FLAG_CANT_STORAGE
        // Data           :     constant 0x2, Constant, Type: int, FLAG_CANT_ENHANCE
        // Data           :     constant 0x3, Constant, Type: int, FLAG_USE
        // Data           :     constant 0x4, Constant, Type: int, FLAG_CARD
        // Data           :     constant 0x5, Constant, Type: int, FLAG_SOCKET
        // Data           :     constant 0x6, Constant, Type: int, FLAG_JOIN
        // Data           :     constant 0x7, Constant, Type: int, FLAG_TARGET_USE
        // Data           :     constant 0x8, Constant, Type: int, FLAG_WARP
        // Data           :     constant 0x9, Constant, Type: int, FLAG_CANT_TRADE
        // Data           :     constant 0xA, Constant, Type: int, FLAG_CANT_SELL
        // Data           :     constant 0xB, Constant, Type: int, FLAG_QUEST
        // Data           :     constant 0xC, Constant, Type: int, FLAG_CANT_USE_OVERWEIGHT
        // Data           :     constant 0xD, Constant, Type: int, FLAG_CASHITEM
        // Data           :     constant 0xE, Constant, Type: int, FLAG_CANT_USE_RIDING
        // Data           :     constant 0xF, Constant, Type: int, FLAG_CANT_DROP
        // Data           :     constant 0x10, Constant, Type: int, FLAG_CANT_USE_MOVING
        // Data           :     constant 0x11, Constant, Type: int, FLAG_QUEST_DISTRIBUTE
        // Data           :     constant 0x12, Constant, Type: int, FLAG_CANT_USE_SIT
        // Data           :     constant 0x13, Constant, Type: int, FLAG_CANT_USE_IN_RAID_SIEGE
        // Data           :     constant 0x14, Constant, Type: int, FLAG_CANT_USE_IN_SECROUTE
        // Data           :     constant 0x15, Constant, Type: int, FLAG_CANT_USE_IN_EVENTMAP
        // Data           :     constant 0x16, Constant, Type: int, FLAG_CANT_USE_IN_HUNTAHOLIC
        // Data           :     constant 0x17, Constant, Type: int, FLAG_USABLE_IN_ONLY_HUNTAHOLIC
        // Enum           :   <unnamed-tag>, Type: int
        // Data           :     constant 0x0, Constant, Type: int, PERMANENT
        // Data           :     constant 0x1, Constant, Type: int, DECREASE_ON_GAME
        // Data           :     constant 0x2, Constant, Type: int, DECREASE_ALWAYS


        public int nCode;                                       // 0x0
        public int nNameId;                                     // 0x4
        public int nType;                                       // 0x8
        public int nGroup;                                      // 0xC
        public ItemClass nClass;                                // 0x10
        public int nSetID;                                      // 0x14
        public int nSetPartFlag;                                // 0x18
        public int nGrade;      
        public int nRank;                                       // 0x1C
        public int nLevel;                                      // 0x20
        public int nEnhance;                                    // 0x24
        public int nSocketCount;                                // 0x28
        public uint nInstanceFlag;                              // 0x2C
        public int nMinLevel;                                   // 0x30
        public int nMaxLevel;                                   // 0x34
        public int nTargetMinLevel;                             // 0x38
        public int nTargetMaxLevel;                             // 0x3C
        public int nRange;                                      // 0x40
        public float fWeight;                                   // 0x44
        public long nPrice;                                     // 0x48
        public int nHuntaholicPoint;                            // 0x50
        public int nDurability;
        public int nEndurance;                                  // 0x54
        public ItemWearType WearType;                           // 0x58
        public int nLimit;                                      // 0x5C
        public uint Flag;                                        // 0x60
        public int nMaterial;                                   // 0x64
        public int nSummonId;                                   // 0x68
        public int nThrowRange;                                 // 0x6C
        public short[] nBaseType = new short[MAX_OPTION_NUMBER];                // 0x70
        public float[] fBaseVar1 = new float[MAX_OPTION_NUMBER];                // 0x78, class c_fixed<10000>[0x4], 
        public float[] fBaseVar2 = new float[MAX_OPTION_NUMBER];                // 0x98, class c_fixed<10000>[0x4], 
        public short[] nOptType = new short[MAX_OPTION_NUMBER];                 // 0xB8
        public float[] fOptVar1 = new float[MAX_OPTION_NUMBER];                 // 0xC0, class c_fixed<10000>[0x4], 
        public float[] fOptVar2 = new float[MAX_OPTION_NUMBER];                 // 0xE0, class c_fixed<10000>[0x4], 
        public short[] nEnhanceID = new short[2];               // 0x100
        public float[,] fEnhanceVar = new float[4,2];              // 0x104, class c_fixed<10000>[0x4], 
        public int nSkillID;                                    // 0x144
        public int nStateCode;                                  // 0x148
        public int nStateLevel;                                 // 0x14C
        public int nStateTime;                                  // 0x150
        public sbyte cStateType;                                // 0x154
        public int nCoolTime;                                   // 0x158
        public short nCoolTimeGroup;                            // 0x15C
        public int available_time;                              // 0x160
        public sbyte decrease_type;                             // 0x164
    }
}
